/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-09-30
 * Time: 23:08
 */
public class TestVer {
//    输入：version1 = "1.2", version2 = "1.10"
//    输出：-1

    public static int compareTo(String s1, String s2) {
        String[] ver1 = s1.split("\\.");
        String[] ver2 = s2.split("\\.");

        int m = ver1.length,n = ver2.length;

        for(int i = 0; i < Math.max(m,n); i++) {
            int v1 = 0, v2 = 0;
            if(i < m) {
                v1 = Integer.parseInt(ver1[i]);
            }
            if(i < n) {
                v2 = Integer.parseInt(ver2[i]);
            }
            if(v1 < v2) {
                return -1;
            }else if(v1 > v2) {
                return 1;
            }
        }
        return 0;
    }



    public static void main(String[] args) {
        String version1 = "1.2";
        String version2 = "1.10";
        int ret = compareTo(version1,version2);
        System.out.println(ret);
    }

}
